<template>
	<view class="content">
		<view class="input-group">
			<view class="phoneclass">
				<text>手机号:</text>
				<input class="input" type="text" v-model="registerphone" placeholder="请输入手机号" />
			</view>
			<br />
			<view class="phoneclass">
				<text>密&nbsp;&nbsp;&nbsp;码:</text>
				<input class="input" type="text" v-model="registerpwd" placeholder="请输入密码" />
			</view>
		</view>

		<button @click="doregister" class="reg">注册</button>
	</view>
</template>

<script>
import { userRegister } from '../../service/index.js';
export default {
	data() {
		return {
			registerphone: '',
			registerpwd: ''
		};
	},
	onLoad() {},
	methods: {
		async doregister() {
			let res = await userRegister(this.registerphone, this.registerpwd);
			// console.log('注册', res);
			if (res.code === 2000) {
				uni.showToast({
					title: '注册成功',
					icon: 'success',
					duration: 3000
				});
				setTimeout(() => {
					uni.navigateBack({
						url: '/pages/login/login'
					});
				}, 1000);
			} else {
				uni.showModal({
					title: '注册失败',
					content: '注册失败：' + res.msg
				});
			}
		}
	}
};
</script>

<style lang="scss">
.input-group {
	display: flex;
	flex-direction: column;
	margin: $uni-spacing-col-lg * 2;
}

.phoneclass {
	display: flex;
	align-items: center;
}

.input {
	font-size: $uni-font-size-base;
	border: 1px solid $uni-border-color;
	border-radius: $uni-border-radius-lg;
	width: 80%;
	height: $uni-font-size-lg * 2.2;
	padding: 0 $uni-spacing-col-base;
	margin-left: $uni-spacing-row-sm;
}
.reg {
	margin: 0 $uni-spacing-col-lg * 3 0;
	background: $zh-theme-color;
	color: $uni-text-color-inverse;
	font-size: $uni-font-size-base;

	&:active {
		background-color: darken($zh-theme-color, 5%);
	}
}
</style>
